package com.xwj.coupon.user.service.event.coupontemplate;

import com.xwj.coupon.user.repository.mysql.entity.CouponTemplateDO;
import com.xwj.coupon.user.repository.redis.CouponTemplateDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @Author: XuWenjie
 * @Date: 2025-08-13
 * @Description: SyncUpdateRedisProcessor
 */
@Component
@Slf4j
public class SyncUpdateRedisProcessor {

    @Autowired
    private CouponTemplateDao couponTemplateDao;

    @EventListener
    private void syncUpdateRedis(CouponTemplateEvent event) {
        log.info("接收到事件:{},同步更新redis", event);
        CouponTemplateDO couponTemplateDO = event.getCouponTemplate();
        couponTemplateDao.setCouponTemplate(couponTemplateDO);

    }
}
